#pragma once


// Copyright (c) 2010 Manuel Peinado Gallego <manuel.peinado@gmail.com>
// Distributed under the MIT license

// GeometryNode.h : interface of the GeometryNode class
//

#include "Geometry.h"
#include "Color.h"
#include "TransformNode.h"


class GeometryNode : public TransformNode
{
public:

    GeometryNode();
    ~GeometryNode();

    // --------------------------------------------------------------

    // We return "const Geometry" because we don't want clients to 
    // modify the shape without us knowing it. So the way to change
    // some property of the shape is 1) get a const ref with 
    // getGeometry. 2) create a non-const clone 3) modify the clone
    // 4) set the clone as the new shape with setShape
    ref<Geometry> getGeometry() const;
    void setGeometry(ref<Geometry> geo);

    // --------------------------------------------------------------

    // --------------------------------------------------------------
    // Drawable overrides
    void draw(View3d * view) const override;

    // --------------------------------------------------------------
    

    // --------------------------------------------------------------
    // Serialization

    void read(std::wistream& is) override;
    void write(std::wostream& os) const override;

protected:

    // Node overrides
    bool canBeDrawnImpl() const { return true; }
    bool isBoundedImpl() const { return true; }
    AABB getAabbLocalImpl() const;

private:

    // ---
    ref<Geometry> m_geo; 
};
